<template>

			
		<uni-section title="" type="line">
					<view class="example">
						<!-- 基础用法，不包含校验规则 -->
						<uni-forms >
							<uni-forms-item label="时间">
								<uni-datetime-picker type="datetime" v-model="baseData.alertTime"   />
							</uni-forms-item>
							<uni-forms-item label="渠道" >
													<uni-data-checkbox v-model="baseData.alertType" multiple :localdata="hobbys" />
												</uni-forms-item>
							<uni-forms-item label="内容" >
								<uni-easyinput v-model="baseData.alertName" placeholder="请输入提醒内容" />
							</uni-forms-item>
						
							<uni-forms-item label="备注">
								<uni-easyinput type="textarea" v-model="baseData.alertRemark" placeholder="请输入提醒备注" />
							</uni-forms-item>
							
								<button type="primary" @click="submit()">创建提醒</button>
						
						
						</uni-forms>
					</view>
				</uni-section>
			
					
				
</template>

<script>
	import store from '@/store/index.js';//需要引入store
	export default {
			data() {
				return {
					baseData: {
						id:"",
						alertName: '',
						alertRemark: '',
						alertTime: '',
					
						alertType: [0],
						
					},
					
					hobbys: [{
										text: '应用内提示',
										value: 0
									}, 
									// {
									// 	text: '微信',
									// 	value: 1
									// }, {
									// 	text: '短信',
									// 	value: 2
									// },
									],
					
				}
			},
	
			watch: {
			
			},
			mounted() {
			
			},
	
			methods:{
				submit(){
					var self=this;
					console.log("aaaaa"+JSON.stringify(self.$data.baseData.alertType[0]))
					let entTime=self.$data.endTime;
					if(self.$data.baseData.alertName.length>0&&self.$data.baseData.alertRemark.length>0&&self.$data.baseData.alertTime.length>0){
						var data={
							"id":self.$data.baseData.id,
							"alertName":self.$data.baseData.alertName,
							"alertRemark":self.$data.baseData.alertRemark,
							"alertTime":self.$data.baseData.alertTime,
							"alertType":self.$data.baseData.alertType[0]
							
							};
						
					
						store.dispatch('addAlertData',data).then(()=>{
							uni.showToast({
								title:"发布成功",
								icon:'none'
							})
							 setTimeout(() => {
								uni.redirectTo({
									url:"/pages/alert/alertList"
								})
							}, 1000);
							
						});
					}else{
						
					}
				},
				change(e) {
					this.single = e
					console.log('change事件:', this.single = e);
				},
				changeLog(e) {
					console.log('change事件:', e);
				},
				maskClick(e){
					console.log('maskClick事件:', e);
				}
			}
		}
</script>

<style>
	.example-body {
			background-color: #fff;
			padding: 10px;
		}
</style>